﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<JLL.China.Web.Areas.Listings.Models.CityModel>" %>

<%@ Import Namespace="System.ComponentModel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/jquery.validation/validationEngine.jquery.css")%>"
        rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Scripts/chosen/chosen.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=Url.Content("~/Content/css/mod-listing.css")%>" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .scrollbox
        {
            height: auto;
            min-width: 580px !important;
            line-height: 18px;
        }
        body
        {
            font: 12px Arial;
        }
        
    </style>

    <script src="<%=Url.Content("~/Scripts/jquery-1.7.2.js")%>" type="text/javascript"></script>

    <!-- -->

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine-en.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/chosen/chosen.jquery.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.mapping.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/Utility.js")%>" type="text/javascript"></script>

    <script>
 var BASE_URL ='<%=Url.Content("~/")%>';
     $(document).ready(function() {
         $("#formID").validationEngine({
             prettySelect: true,
             useSuffix: "_chzn",
             promptPosition: "topLeft"
         });
         $(".chz").chosen({
             allow_single_deselect: true
         });
           $(".chzn-nosearch").chosen({ disable_search_threshold: 3, allow_single_deselect: true });
         
         //check city name
         $.ajaxSetup({ cache: false });
            $("#city_inter").bind("keyup change blur", function() {
                var data = $(this).val();
                var country = $("#country").val();
                if (data.length == 0) {
                    $("#checkitem_inter").text("");
                    $("#checkitem_inter").removeClass("green");
                    $("#checkitem_inter").removeClass("red");
                } else {
                    $.ajax({
                        url: BASE_URL + "Listings/City/CheckName",
                        type: 'POST', // POST or GET
                        data: { name: data, countryId:country,where:'1'},
                        success: function(result, status) {
                            if (result == "YES") {
                                $("#checkitem_inter").text("That name  is already in use.");
                                $("#checkitem_inter").removeClass("green");
                                $("#checkitem_inter").addClass("red");

                            } else {
                                $("#checkitem_inter").text("");
                                $("#checkitem_inter").removeClass("red");
                                // $(".checkitem").addClass("green");

                            }
                        }
                    }
		);

                }
            });
         
         
         //check name local
          $.ajaxSetup({ cache: false });
            $("#city_local").bind("keyup change blur", function() {
                var data = $(this).val();
             var country = $("#country").val();
                if (data.length == 0) {
                    $("#checkitem_local").text("");
                    $("#checkitem_local").removeClass("green");
                    $("#checkitem_local").removeClass("red");
                } else {
                    $.ajax({
                        url: BASE_URL + "Listings/City/CheckName",
                        type: 'POST', // POST or GET
                        data: { name: data,countryId:country,where:'2'},
                        success: function(result, status) {
                            if (result == "YES") {
                                $("#checkitem_local").text("That name  is already in use.");
                                $("#checkitem_local").removeClass("green");
                                $("#checkitem_local").addClass("red");

                            } else {
                                $("#checkitem_local").text("");
                                $("#checkitem_local").removeClass("red");
                                // $(".checkitem").addClass("green");

                            }
                        }
                    }
		);

                }
            });
     });

        <% if(ViewData["SaveAction"]!=null)
           {%>
        window.parent.location.href = window.parent.location.href;
        <% } %>
       
    </script>

    <title>Edit</title>
</head>
<body>
    <% using (Html.BeginForm("Update", "City", FormMethod.Post, new { id = "formID", enctype = "multipart/form-data", @class = "validateform" }))
       { %>
    <%= Html.HiddenFor(x => x.City_Inter.CityID) %>
    <%= Html.HiddenFor(x => x.City_Local.CityID) %>
    <%= Html.HiddenFor(x => x.City_Inter.LanguageFID) %>
    <%= Html.HiddenFor(x => x.City_Local.LanguageFID) %>
    <%= Html.HiddenFor(x => x.City_Inter.CityCode) %>
    <%= Html.HiddenFor(x => x.City_Local.CityCode) %>
    <% if (Model.City_Inter != null)
       { %>
    <p>
        <h3 style="margin-left: 8px">
            Update City Name
        </h3>
    </p>
    <% }
       else
       { %>
    <p>
        <h3 style="margin-left: 8px">
            Insert City
        </h3>
    </p>
    <% } %>
    <table align="center" cellpadding="10" cellspacing="10" class="style1" style="padding: 5px"
        width="">
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Country
            </td>
            <td style="width: 50%">
                <%=Html.DropDownListFor(x => x.City_Inter.Country_ID, new SelectList(Model.CountryList, "Country_ID", "Country_EN"), new { id = "country", name = "country", @class = "chz", style="width:350px" })%>
            </td>
        </tr>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>City name( Enlish)
            </td>
            <td style="width: 50%">
                <%= Html.TextBoxFor(x => x.City_Inter.CityName,
                                               new
                                                   {
                                                       name = "city_inter",
                                                       id = "city_inter",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %>
                <a class="checkitem" id="checkitem_inter"></a>
            </td>
        </tr>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>City name( Local)
            </td>
            <td style="width: 50%">
                <%= Html.TextBoxFor(x => x.City_Local.CityName,
                                               new
                                                   {
                                                       name = "city_local",
                                                       id = "city_local",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %>
                <a class="checkitem" id="checkitem_local"></a>
            </td>
        </tr>
        <tr>
            <%-- <td style="width:30%">
                <font color="red">(*)</font>City code</td>
              <td style="width:50%">
                  <%= Html.TextBoxFor(x => x.City_Inter.CityCode,
                                               new
                                                   {
                                                       name = "country_cn",
                                                       id = "country_cn",
                                                       @class = "validate[required] inp-form",
                                                       style = "width: 100%"
                                                   }) %></td>--%>
        </tr>
        <tr>
            <td style="width: 30%">
                <font color="red">(*)</font>Status
            </td>
            <td style="width: 50%">
                <%=Html.DropDownListFor(m => m.City_Inter.Status, new List<SelectListItem>
                     {
                        new SelectListItem{Selected = true, Text="Active", Value = "true" }, 
                        new SelectListItem{Selected = false, Text="Inactive", Value = "false" },
                     }, new { id = "city_status", name = "city_status", @class = "chzn-nosearch ", style ="width:200px"})%>
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td width="20%" align="right">
                <input type="button" value="Cancel" class="buttons" style="margin-right: 18px; float: right;
                    cursor: pointer" onclick="window.parent.location='<%= Url.Content("~/Listings/City/Index") %>'" />
                <input type="submit" value="Save" class="buttons" style="margin-right: 8px; float: right" />
            </td>
        </tr>
    </table>
    <% } %>
</body>
</html>
